<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title th:text="${ys.pm}+' - 淡白影视'"></title>
    <meta name="Keywords"  th:content="'淡白影视,淡白电影,淡白电视剧,淡白综艺,免vip弹幕影视,弹幕影视,最新电影,'+${ys.pm}+','+${ys.pm}+'在线观看,'+${ys.zy}+','+${ys.dy}"/>
    <meta name="Description" th:content="${ys.js}"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="icon" href="https://cdn.p00q.cn/favicon.ico">
    <link rel="stylesheet" href="https://cdn.p00q.cn/ys/css/bootstrap.min.css">
    <script src="https://cdn.p00q.cn/ys/js/jquery.min.js"></script>
    <script src="https://cdn.p00q.cn/ys/js/bootstrap.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/cdnbye@latest"></script>
    <script src="https://cdn.jsdelivr.net/npm/p2p-dplayer@latest"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
    <link rel="stylesheet" rev="stylesheet" type="text/css" media="all" href="https://cdn.p00q.cn/ys/css/bootadd.css">
    <link rel="stylesheet" rev="stylesheet" type="text/css" media="all" href="https://cdn.p00q.cn/ys/css/css2.css">
    <th:block th:utext="${head}" />
</head>
<body>
<div style="background:#FFF" th:include="include/include :: dhl">
</div>
<div class="container">
    <div class="container-fluid" style="padding-top:15px;background:#FFF;position:relative">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-4" style="padding-right:5px;">
                    <img class="img-thumbnail" width="100%" th:src="${ys.tp}" th:alt="${ys.pm}">
                    <button class="hdtag" th:text="${ys.zt}">高清中字</button>
                </div>
                <div style="margin:10px auto;">
                    <em th:text="'更新时间：'+${ys.gxtime}"></em></div>
                <div class="col-md-8" style="padding-right:5px;">
                    <table class="table table-striped table-condensed table-bordered"
                           style="margin-bottom:10px;font-size:12px;">
                        <tbody>
                        <tr>
                            <td class="span2">
                                <span class="info-label">导演</span></td>
                            <td th:text="${ys.dy}"></td>
                        </tr>
                        <tr>
                            <td class="span2">
                                <span class="info-label">主演</span></td>
                            <td id="casts" style="position:relative;" th:text="${ys.zy}">

                            </td>
                        </tr>
                        <tr>
                            <td class="span2">
                                <span class="info-label">类型</span></td>
                            <td th:text="${ys.lx}"></td>
                        </tr>
                        <tr>
                            <td class="span2">
                                <span class="info-label">制片国家</span></td>
                            <td th:text="${ys.dq}"></td>
                        </tr>
                        <tr>
                            <td class="span2">
                                <span class="info-label">更新状态</span></td>
                            <td th:text="${ys.zt}">高清中字</td>
                        </tr>
                        <tr>
                            <td class="span2">
                                <span class="info-label">播放时间</span></td>
                            <td th:text="${ys.sytime}"></td>
                        </tr>
                        <tr>
                            <td class="span2">
                                <span class="info-label">评分</span></td>
                            <td th:text="${ys.pf}">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <p style="color:#777;">
                        <strong>剧情介绍：</strong></p>
                    <p class="summary" th:text="${ys.js}"></p>
                </div>
            </div>
            <div class="row" style="margin-top:10px;"></div>
        </div>
        <span></span><h3 class="movie-title" th:text="'影视名称：'+${ys.pm}"></h3>抓取弹幕:<input id="zdm" type="checkbox" checked></span>
        <h4 id="jxs" th:text="${jiname}"></h4>
        <div class="player" id="player">
            <div id="dplayer"></div>
        </div>
        <div class="col-md-12">
            <div class="panel panel-default resource-list">
                <div class="panel-heading"><strong
                        th:text="'《'+${ys.pm}+'》 - 1.在线视频 (支持手机)高清资源 - 在线播放 - 如果不能播放先刷新试试：'"></strong></div>
                <ul class="dslist-group">
                    <li class="dslist-group-item on" th:each="ji : ${xs}">
                        <span style="cursor:pointer;background-color: #6495ED;color: #FFF;margin: 3px;  padding: 5px 12px 5px 10px;text-decoration: none;"
                              class="ji" th:text="${ji.name}" th:value="${ji.url}"></span>
                    </li>
                </ul>
                <div class="panel-footer resource-help" style="clear: both;">
                    <strong th:text="'《'+${ys.pm}+'》 - 资源观看帮助：'"></strong><br>
                    1、有个别电影打开后播放需要等待。<br>
                    2、如果电影打开不能播放请留言给我们，我们更换资源。<br>
                    3、有的播放不了请多刷新几下，试试。
                    4、弹幕抓取错误的可以关闭抓取
                    5、反馈邮箱:db225@qq.com
                </div>
            </div>
        </div>
    </div>
</div>
<footer class="footer" th:include="include/include :: foot"></footer>
<script th:inline="javascript">
    /*<![CDATA[*/
    var user = /*[[${session.user}]]*/ null;
    /*]]>*/

    if (user == null) {
        var username = "user";
    } else {
        var username = user.username;
    }
</script>
<script th:if="${xs!=null}">
    tagid = 0;
    var fstys = "[[${url}]]";
    var ysid = "[[${ysid}]]";
    var id = "[[${ys.id}]]";
    var jiname = "[[${jiname}]]";
    var timeout = true; //启动及关闭按钮
    var dmtimeout = true;
    var jii=0;
    const dp = new DPlayer({
        container: document.getElementById('dplayer'),
        logo: 'https://cdn.p00q.cn/ys/img/logo.png',
        autoplay: true,
        theme: '#FFFFF0',
        video: {
            url: fstys,
            pic: 'https://cdn.p00q.cn/ys/img/tip.png'
        },
        danmaku: {
            id: ysid,
            api: 'https://dm.dbys.vip/',
            user: username,
            bottom: '15%',
            unlimited: true
        }, contextmenu: [
            {
                text: '淡白博客',
                link: 'https://p00q.cn',
            }]
    })
    dp.seek(gettime());
    $(".ji").click(function () {
        $(".ji").each(function () {
            $(this).css({"background-color":"#6495ED"});
        })
        $(this).css({"background-color":"#FF6347"});
        ysid = id + $(this).html();
        var $this = $(this).parent();
        $(this).parent().parent().children().each(function (i, o) {
            if ($this[0] === $(o)[0]) {
                gettagid(i);
            }
        })
        $("#jxs").text($(this).text());
        jiname = $(this).text();
        timeout = false;
        dp.switchVideo({
            url: $(this).attr("value"),
            pic: 'https://cdn.p00q.cn/ys/img/tip.png'
        }, {
            id: ysid,
            api: 'https://dm.dbys.vip/',
            user: username
        });
        dp.notice("正在加载请稍后!");
        dp.seek(gettime());
        dp.play();
        timeout = true;
    });
    dp.on('ended', function () {
        getjii()
        var nexitji = $(".dslist-group").children().eq( jii+ 1).children().eq(0);
        jii++;
        if (nexitji.html != null) {
            $("#jxs").text(nexitji.text());
            jiname = nexitji.text();
            timeout = false;
            ysid = id + jiname;
            gettagid();
            dp.switchVideo({
                url: nexitji.attr("value"),
                pic: 'https://cdn.p00q.cn/ys/img/tip.png'
            }, {
                id: ysid,
                api: 'https://dm.dbys.vip/',
                user: username
            });
            dp.notice("自动播放下一集!");
            //dp.seek(gettime());
            dp.play();
            timeout = true;
        }
        swcolor();
    });
    dp.on('pause', function () {
        dmtimeout = false;
        setTimeout(function () {
            if (dp.video.paused) {
                if (!dmtimeout) {
                    dmtimeout = true;
                    dmdsq();
                }
            }
        }, 30000);
    });
    dp.on('play', function () {
        dmtimeout = true;
    });

    //定时器puttime
    function dsj() {
        if (!timeout) return;
        puttime();
        setTimeout(dsj, 5000); //time是指本身,延时递归调用自己,5000为间隔调用时间,单位毫秒
    }

    //定时器getdanmu
    function dmdsq() {
        if (!dmtimeout) return;
        if (tagid != 0) {
            if (!dp.video.paused) {
                if($("#zdm").is(':checked')){
                    getdm(tagid, ~~(dp.video.currentTime + 30));
                }
            }
        }
        setTimeout(dmdsq, 30000);
    }

    function puttime() {
        $.post("/ys/time",
            {
                ysid: id,
                username: username,
                time: dp.video.currentTime,
                ysjiname: jiname
            });
    }

    function gettime() {
        var result = "";
        $.ajax({
            type: "POST",
            url: '/ys/gettime',
            data: {ysid: id, username: username, ysjiname: jiname},
            async: false,//同步
            success: function (data) {
                result = data;
            }, failure: function () {
                result = "";
            }
        })
        return result;
    }

    $(document).ready(function () {
        getjii()
        gettagid();
        dmdsq();
        if (username != "user") {
            dsj();
        }
    });
    function swcolor() {
        $(".ji").each(function () {
            $(this).css({"background-color":"#6495ED"});
        })
        $(".ji").eq(jii).css({"background-color":"#FF6347"});
    }
    function gettagid() {
        $.ajax({
            type: "GET",
            url: '/ys/gettagid',
            data: {pm: "[[${tagpm}]]", ysid: ysid},
            success: function (data) {
                if (data != "") {
                    tagid = data;
                    getdm(tagid, ~~(dp.video.currentTime));
                }
            }
        })
    }

    function getjii() {
        $(".dslist-group").children().each(function(i,n){
            var obj = $(n)
            if(obj.children().eq(0).html()==jiname){
                jii=i;
            }
        });
        swcolor();
    }
    function getdm(id, time) {
        $.getJSON("https://mfm.video.qq.com/danmu?otype=json&target_id=" + id + "&timestamp=" + time, function (json) {
            ds = []
            $.each(json.comments, function (i, d) {
                ds.push(d)
            });
            ds = ds.sort(function (a, b) {
                return (a.timepoint > b.timepoint) ? 1 : ((a.timepoint < b.timepoint) ? -1 : 0);
            });
            $.each(ds, function (i, d) {
                adddm({
                    text: d.content,
                    color: 16777215,
                    type: 0,
                    time: d.timepoint,
                    author: "user"
                })
            });
            dp.danmaku.dan = dp.danmaku.dan.sort(function (a, b) {
                return (a.time > b.time) ? 1 : ((a.time < b.time) ? -1 : 0);
            });
        });
    }

    function adddm(dm) {
        dp.danmaku.dan.push(dm);
    }
</script>
</body>
</html>
